<template>
  <div class="search-contract">
    <div class="button-text" @click="openDialog">查看合同</div>
    <RelatedContract
      v-if="showRelatedContract"
      ref="showRelatedContract"
      :visible.sync="showRelatedContract"
      :expand-params="{oppCompanyType: oppCompanyType}"
      hide-select-tab
      show-filter-opp-company-id
      is-show-other
      title="合同列表" />
  </div>
</template>

<script>
import RelatedContract from '@/components/CreateOrder/relatedContract';
export default {
  name: 'SearchContract',
  components: { RelatedContract },
  props: {
    oppCompany: { // 签约主体
      type: String | Number,
      default: ''
    },
    oppCompanyId: { // 签约主体ID
      type: String | Number,
      default: ''
    },
    oppCompanyType: { // 签约主体类型 0：飞博供应商 1：有赞供应商 2：萌力供应商 3：销售客户 4：萌力客户
      type: Number,
      default: 0
    }
  },
  data() {
    return {
      showRelatedContract: false
    };
  },
  methods: {
    openDialog() {
      this.showRelatedContract = true;
      this.$nextTick(() => {
        if (!this.oppCompanyId) {
          this.$refs.showRelatedContract.setParams('oppCompany', this.oppCompany);
        } else {
          this.$refs.showRelatedContract.setParams('oppCompanyId', this.oppCompanyId);
        }
      });
    }
  }
};
</script>

<style lang="scss" scoped>
.search-contract {
  flex-shrink: 0;
  margin-left: 5px;
  .button-text {
    font-weight: bold;
  }
}
</style>
